import { defineStore } from 'pinia';
import { getCategories, getHomeHouselist, getHotSuggests } from '@/services/modules/home.js';
const useHomeStore = defineStore('home', {
  state: () => ({
    hotCities: [],
    categories: [],
    currentPage: 1,
    houselist: [],
  }),
  actions: {
    async fetchHotCitiesData() {
      const res = await getHotSuggests();
      this.hotCities = res.data;
    },
    async fetchCategoriesData() {
      const res = await getCategories();
      this.categories = res.data;
    },
    async fetchHouselistData() {
      const res = await getHomeHouselist(this.currentPage);
      this.houselist.push(...res.data);
    },
  },
});
export default useHomeStore;
